﻿using System;
using System.Windows.Forms;

namespace Options.IBClient.WinApp.Extensions
{
   public static class TextBoxExtensions
   {
      public static void WriteLine(this TextBox textBox)
      {
         textBox.InvokeIfNeeded(delegate
         {
            textBox.AppendText("\r\n");
         }, InvocationMethod.Asynchronous);
      }

      public static void WriteLine(this TextBox textBox, string message)
      {
         if (!String.IsNullOrEmpty(message))
         {
            textBox.InvokeIfNeeded(delegate
            {
               textBox.AppendText(message);
               textBox.AppendText("\r\n");
            }, InvocationMethod.Asynchronous);
         }
      }

      public static void Write(this TextBox textBox, string message)
      {
         if (!String.IsNullOrEmpty(message))
         {
            textBox.InvokeIfNeeded(delegate
            {
               textBox.AppendText(message);
            }, InvocationMethod.Asynchronous);
         }
      }
   }
}
